#pragma once

#include <MyFC/Widget.h>
#include <MyFC/Container.h>
#include <MyFC/Glyph.h>

#include "Types.h"
#include "DLL.h"

namespace My {

class Timeline;

class DLL_API ThumbLine : public Widget, public Container
{
	class Control : public My::Control 
	{
	protected:
		ThumbLine &			m_ThumbLine;
		Timeline &			m_Timeline;
	public:
		Control(ThumbLine &);
		virtual bool Visible() const;
	};

	class LeftBracket : public Control
	{
	private:
		int		m_StartPos;
		int		m_StartValue;
	public:
		LeftBracket(ThumbLine & t) : Control(t) { }
	public:
		virtual CRect Bounds() const;
		virtual String Hint() const; 
;		virtual bool HandleDragStart(unsigned int flags, const CPoint & p0, const CPoint & p);
		virtual void HandleDragEnd(unsigned int flags, const CPoint & p);
		virtual void HandleDragging(unsigned int flags, const CPoint & p);
	};

	class RightBracket : public Control
	{
	private:
		int		m_StartPos;
		int		m_StartValue;
	public:
		RightBracket(ThumbLine & t) : Control(t) { }
	public:
		virtual CRect Bounds() const;
		virtual String Hint() const; 
;		virtual bool HandleDragStart(unsigned int flags, const CPoint & p0, const CPoint & p);
		virtual void HandleDragEnd(unsigned int flags, const CPoint & p);
		virtual void HandleDragging(unsigned int flags, const CPoint & p);
	};

	class Grip : public Control
	{
	private:
		int		m_StartPos;
		int		m_StartValue;
		int		m_Size;
	public:
		Grip(ThumbLine & t) : Control(t) { }
	public:
		virtual CRect Bounds() const;
		virtual String Hint() const; 
		virtual bool Visible() const;
		virtual bool HandleDragStart(unsigned int flags, const CPoint & p0, const CPoint & p);
		virtual void HandleDragEnd(unsigned int flags, const CPoint & p);
		virtual void HandleDragging(unsigned int flags, const CPoint & p);
	};

	class Thumb : public Control
	{
	private:
		int	m_StartPos;
		int	m_StartValue;
	public:
		Thumb(ThumbLine & t) : Control(t) { }
	public:
		virtual CRect Bounds() const;
		virtual String Hint() const;
		virtual bool HandleDragStart(unsigned int flags, const CPoint & p0, const CPoint & p);
		virtual void HandleDragEnd(unsigned int flags, const CPoint & p);
		virtual void HandleDragging(unsigned int flags, const CPoint & p);
	};

public:
	My::SysColorGlyph	m_ThumbGlyph;
	My::SysColorGlyph	m_WALeft;
	My::SysColorGlyph	m_WARight;
	My::SysColorGlyph	m_WAThumb;
public:
	ThumbLine(Timeline & t);
public:
	virtual String Hint() const;
	virtual void ProcessEvent(Event &);
	virtual void HandleLeftDown(unsigned int flags, const CPoint & p);
	virtual void HandleLeftUp(unsigned int flags, const CPoint & p);
	virtual void HandlePaint(CDC * pDC, const CRect & r);
private:
	Timeline &			m_Timeline;
	LeftBracket			m_LeftBracket;
	RightBracket		m_RightBracket;
	Grip				m_Grip;
	Thumb				m_Thumb;
};

} // My